<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'filesystem_toolbox/filesystem_functions.inc.php');

require_once($WSC->get_site_inc_dir().'modules/admin_panel/site_admin_web_page_wed_ua.class.php');

require_once($WSC->get_site_inc_dir().'modules/tree_menu/tree_menu_dbc.class.php');
require_once($WSC->get_site_inc_dir().'modules/admin_panel/classes/admin_user/admin_user_dbc.class.php');


class Log_Exceptions_WP extends Site_Admin_Web_Page_WED_UA {
	public function init() {
		parent::init();

		$v = $this->create_view();
		$this->add_view($v);

		$this->wed->add_wed_event_action_pair(new Web_Event_Simple_Int('empty', Tangra_Parameter_Method::GET, 'empty'), 'empty_event');
	}


	protected function default_event() {
		$exceptions_log_file = $this->_config->get_logs_dir().'exceptions.log';
		if (file_exists($exceptions_log_file)) {
			$content = file_get_contents($exceptions_log_file);
			$this->export('log_content', $content);
		}


		$view = $this->get_view('default');

		return $view;
	}


	protected function empty_event($params) {
		$exceptions_log_file = $this->_config->get_logs_dir().'exceptions.log';
		if (file_exists($exceptions_log_file)) {
			unlink($exceptions_log_file);
		}

		empty_dir($this->_config->get_debug_dir());

		return $this->default_event();
	}
}